/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package agents;

import java.io.IOException;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import env.Action;
import env.Orientation;
import env.Enviroment;
import java.awt.Color;
import javax.swing.Icon;
import javax.swing.ImageIcon;

/**
 *
 * @author orcas
 */
public class HumanAgentOptionDialog extends Agent {
    static Icon iconNorth=new ImageIcon("images/ShipNorth.gif");
    static Icon iconSouth=new ImageIcon("images/ShipSouth.GIF");
    static Icon iconEast=new ImageIcon("images/ShipEast.GIF");
    static Icon iconWest=new ImageIcon("images/ShipWest.GIF");

    private JPanel frame;

    public HumanAgentOptionDialog(String name, int row, int col, Orientation orientation, Color color) {
        super(name, row, col, orientation, color);
        frame = new JPanel();
    }

    public Action getMove1(Enviroment env) {
        int str = -1;
        System.out.print("a/w/d");
        try {
            str = System.in.read();
            switch (str) {
                case 'a':
                    return Action.left;
                case 'w':
                    return Action.fwd;
                case 'd':
                    return Action.right;
                case 'q':
                    System.exit(0);
            }

        } catch (IOException e) {
        }
        return null;
    }

    public Action getMove() {
        Object[] direction = {"<-", "^", "->"};
        int n = JOptionPane.showOptionDialog(frame,
                "Select a move", "AI human agent",
                JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE,
                null,
                direction,
                direction[1]);
        //System.out.println("**" + n + "**");
        switch (n) {
            case 0:
                return Action.left;
            case 1:
                return Action.fwd;
            case 2:
                return Action.right;
            default:
                System.exit(0);
        }
        return null;
    }
    
    @Override
    public Icon getIcon() {
        switch(this.getOrientation()) {
            case North: return iconNorth;
            case East: return iconEast;
            case West: return iconWest;
            case South: return iconSouth;
        }
        return null;
    }
}
